package com.example.fmgidsprototype.webservice;

import com.example.fmgidsprototype.AppConstants;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class n_cst_common {
	public static String of_get_user_name(Context anv_context)
	{
		String ls_user_name = of_get_preference(anv_context, "username");
		return ls_user_name;
	}
	
	public static String of_get_preference(Context anv_context, String as_key)
	{
		//SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(anv_context);
		SharedPreferences preferences = anv_context.getSharedPreferences(AppConstants.PREFS_IDENTIFIER, Context.MODE_PRIVATE);
		return preferences.getString(as_key, "n/a");		
	}
	
	public static void of_set_user_name(Context anv_context, String as_value)
	{
		of_set_preference(anv_context, "username", as_value);
	}
	
	public static void of_set_preference(Context anv_context, String as_key, String as_value)
	{
		//SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(anv_context); 
		SharedPreferences preferences = anv_context.getSharedPreferences(AppConstants.PREFS_IDENTIFIER, Context.MODE_PRIVATE);
		Editor edit = preferences.edit();
		edit.putString("username", as_value);
		edit.commit();
	}
}
